package org.jwos.platform.ajax;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

public class JSONUtil {
	
	public static String getDataString(InputStream input,int length) {

		String data = null;
		
		try {
			byte[] buf = new byte[length];
			byte[] ch = new byte[1];
			int count = 0;
			while (count < buf.length) {
				if (input.read(ch) > 0) {
					buf[count] = ch[0];
					count++;
				}
			}
			
			data = new String(new String(buf, "ISO-8859-1").getBytes("ISO-8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}		
		
		return data;
	}	
}
